#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>

void PrintArr(int* a, int n)
{
	for (int i = 0; i < n; i++)
	{
		printf("%d ", a[i]);
	}
	printf("\n");
}
void shellSort(int* a,int n)
{
	int gap = n;
	while (gap > 1)
	{
		gap = gap / 3 + 1;
		for (int i = 0; i < n - gap; i++)
		{
			int end = i;
			int temp = a[i+gap];
			while (end >= 0)
			{
				if (a[end] > temp)
				{
					a[end + gap] = a[end];
					end-=gap;
				}
				else
					break;
			}
			a[end + gap] = temp;
		}
	}

}
int main()
{
	int arr[11] = { 9,5,6,7,8,9,1,2,3,4 };
	shellSort(arr, sizeof(arr) / sizeof(int));
	PrintArr(arr, sizeof(arr) / sizeof(int));
	return 0;
}